import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

    public class Book {
         final String isbn;
         final String title;
         final String author;
         final String category;
         boolean available;
         LocalDate dueDate;
         String borrowedBy; // 新增：记录借阅者ID

        public Book(String isbn, String title, String author, String category) {
            this.isbn = isbn;
            this.title = title;
            this.author = author;
            this.category = category;
            this.available = true;
            this.borrowedBy = "";
        }

        // Getter和Setter方法
        public String getIsbn() { return isbn; }
        public String getTitle() { return title; }
        public String getAuthor() { return author; }
        public String getCategory() { return category; }
        public boolean isAvailable() { return available; }
        public LocalDate getDueDate() { return dueDate; }
        public String getBorrowedBy() { return borrowedBy; } // 新增

        public void setAvailable(boolean available) { this.available = available; }
        public void setDueDate(LocalDate dueDate) { this.dueDate = dueDate; }
        public void setBorrowedBy(String userId) { this.borrowedBy = userId; } // 新增

        @Override
        public String toString() {
            return String.format("%s - %s (%s) [%s]", title, author, isbn,
                    available ? "可借阅" : "已借出，应还日期: " + dueDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
        }
    }

